home *** CD-ROM | disk | FTP | other *** search
/ Aminet 2 / Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso / Aminet / dev / misc / ImageFXDevKit.lha / sdev / sas / examples / loaders / skeleton.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-02  |  5.0 KB  |  187 lines

  1. /*
  2.  * Skeleton Loader Module, on which to base other loaders
  3.  *
  4.  */
  5.  
  6. #include <scan/modall.h>
  7. #include <scan/loadsave.h>
  8.  
  9.  
  10. /************************************************************************
  11.  * LM_Load() - Load an image from the given file
  12.  *
  13.  * Attempt to load the contents of the given file and convert it
  14.  * to 24-bits if necessary.  Should return a valid Buffer (see
  15.  * scan/buf.h) structure filled out properly.
  16.  *
  17.  * Returns a pointer to a Buffer structure if successful or
  18.  * NULL on failure, with an addition error code set by using
  19.  * SetError().
  20.  *
  21.  * Inputs:
  22.  *
  23.  *    fname    - name of file to load
  24.  *    id       - ID code (as provided by LM_Signatures below)
  25.  *    args     - Arexx arguments
  26.  */
  27.  
  28. struct Buffer * __saveds __asm LM_Load (register __a0 char *fname,
  29.                                         register __d0 int id,
  30.                                         register __a1 LONG *args)
  31. {
  32.    InfoRequest("LM_Load");
  33.    ReturnError(ERR_UserCancel, NULL);
  34. }
  35.  
  36. /************************************************************************
  37.  * LM_LoadPalette() - Load a palette from file
  38.  *
  39.  * Attempts to extract palette information from the given file.
  40.  * This function should fill in the supplied Palette structure (see
  41.  * scan/loadsave.h) as best it can.  Specifically, you need to fill
  42.  * in the Depth, Count, and Table fields at least.  Others are
  43.  * optional.
  44.  *
  45.  * Return TRUE if successful, FALSE on failure with an additional
  46.  * error code set by using SetError().
  47.  *
  48.  * Inputs:
  49.  *
  50.  *    fname    - name of file to load
  51.  *    pal      - struct Palette to fill in
  52.  *    id       - ID code (as provided by LM_Signatures below)
  53.  *
  54.  */
  55.  
  56. BOOL __saveds __asm LM_LoadPalette (register __a0 char *fname,
  57.                                     register __a1 struct Palette *pal,
  58.                                     register __d0 int id)
  59. {
  60.    InfoRequest("LM_LoadPalette");
  61.    ReturnError(ERR_NoPalette, FALSE);
  62. }
  63.  
  64. /************************************************************************
  65.  * Format descriptor table - describes the bytes to look for at the
  66.  * beginning of a file, the name of the format, and flags.  The table
  67.  * ends with a NULL entry.
  68.  *
  69.  * See also struct LoadFormat in <scan/loadsave.h>.
  70.  *
  71.  */
  72. static
  73. struct LoadFormat loadformats[] = {
  74.    { "GUST", 4, "Guschtumple", 0 },
  75.    { NULL }
  76. };
  77.  
  78. /************************************************************************
  79.  * LM_Signatures() - Return signature bytes
  80.  *
  81.  * Tell ImageFX the signature byte(s) you look for at the beginning
  82.  * of a file.  Given as an array of struct LoadFormat (see scan/loadsave.h).
  83.  *
  84.  * Return NULL if you want to use custom file identification.
  85.  *
  86.  */
  87.  
  88. struct LoadFormat * __saveds LM_Signatures (void)
  89. {
  90.    return (loadformats);
  91. }
  92.  
  93. /************************************************************************
  94.  * LM_CheckFile() - Custom file identification
  95.  *
  96.  * Only called if you returned NULL from LM_Signatures() above.
  97.  * You should return TRUE if you are able to load the file specified
  98.  * by "fname", or FALSE if you don't recognize it.
  99.  *
  100.  * Inputs:
  101.  *
  102.  *    fname    - name of file to check
  103.  *
  104.  */
  105.  
  106. BOOL __saveds __asm LM_CheckFile (register __a0 char *fname)
  107. {
  108.    return(FALSE);
  109. }
  110.  
  111.  
  112. /**********************************************************************\
  113.  
  114.                          Standard Module Stuff
  115.  
  116. \**********************************************************************/
  117.  
  118.  
  119. /************************************************************************
  120.  * Function table.  Referenced in "lib.o".
  121.  *
  122.  * The first four entries are the standard library vectors, defined
  123.  * in "lib.o", the remaining entries define functions specific to
  124.  * this module.
  125.  *
  126.  * The table ends with -1.
  127.  *
  128.  */
  129. ULONG FuncTable[] = {
  130.    (ULONG) LibOpen,
  131.    (ULONG) LibClose,
  132.    (ULONG) LibExpunge,
  133.    (ULONG) LibNull,
  134.  
  135.    (ULONG) LM_Load,
  136.    (ULONG) LM_LoadPalette,
  137.    (ULONG) LM_Signatures,
  138.    (ULONG) LM_CheckFile,
  139.  
  140.    (ULONG) -1L
  141. };
  142.  
  143. /************************************************************************
  144.  * ID string for this module.  References in "lib.o".
  145.  *
  146.  * Should be given in the standard 2.0 version string style.
  147.  */
  148. UBYTE LibraryID[] = "$VER: Untitled 1.00.00 (19.6.92)";
  149.  
  150. /************************************************************************
  151.  * Type of module.  Referenced in "lib.o".
  152.  *
  153.  * Should be one of the NT_* defines in <scan/mod.h>
  154.  *
  155.  */
  156. UBYTE LibraryType = NT_LOADER;
  157.  
  158. /************************************************************************
  159.  * Module initialization code.  Referenced by "lib.o".
  160.  *
  161.  * This is where you would initialize the ModuleBase structure that
  162.  * is passed to you.
  163.  *
  164.  * Returns TRUE if all went well, or FALSE if something went wrong and
  165.  * the module open should fail.
  166.  *
  167.  */
  168. LONG __saveds __stdargs UserOpen (struct ModuleBase *modbase)
  169. {
  170.    return(TRUE);
  171. }
  172.  
  173. /************************************************************************
  174.  * Module cleanup code.  Referenced by "lib.o".
  175.  *
  176.  * This should cleanup anything you allocated or opened in UserOpen()
  177.  * above.
  178.  *
  179.  * Always return TRUE.
  180.  *
  181.  */
  182. LONG __saveds __stdargs UserClose (struct ModuleBase *modbase)
  183. {
  184.    return(TRUE);
  185. }
  186.  
  187.